# +----------------------------------------------------------------------
# | DjangoAdmin敏捷开发框架 [ 赋能开发者，助力企业发展 ]
# +----------------------------------------------------------------------
# | 版权所有 2021~2024 北京DjangoAdmin研发中心
# +----------------------------------------------------------------------
# | Licensed LGPL-3.0 DjangoAdmin并不是自由软件，未经许可禁止去掉相关版权
# +----------------------------------------------------------------------
# | 官方网站: https://www.djangoadmin.cn
# +----------------------------------------------------------------------
# | 作者: @一米阳光 团队荣誉出品
# +----------------------------------------------------------------------
# | 版权和免责声明:
# | 本团队对该软件框架产品拥有知识产权（包括但不限于商标权、专利权、著作权、商业秘密等）
# | 均受到相关法律法规的保护，任何个人、组织和单位不得在未经本团队书面授权的情况下对所授权
# | 软件框架产品本身申请相关的知识产权，禁止用于任何违法、侵害他人合法权益等恶意的行为，禁
# | 止用于任何违反我国法律法规的一切项目研发，任何个人、组织和单位用于项目研发而产生的任何
# | 意外、疏忽、合约毁坏、诽谤、版权或知识产权侵犯及其造成的损失 (包括但不限于直接、间接、
# | 附带或衍生的损失等)，本团队不承担任何法律责任，本软件框架禁止任何单位和个人、组织用于
# | 任何违法、侵害他人合法利益等恶意的行为，如有发现违规、违法的犯罪行为，本团队将无条件配
# | 合公安机关调查取证同时保留一切以法律手段起诉的权利，本软件框架只能用于公司和个人内部的
# | 法律所允许的合法合规的软件产品研发，详细声明内容请阅读《框架免责声明》附件；
# +----------------------------------------------------------------------

from datetime import datetime
from sqlalchemy import Column, String, Integer, Date, Float, DateTime, DECIMAL

from apps.models.base_db import base_db
from apps.models.base_model import base_model
from config.env import DB_PREFIX


# 用户模型
class DataOrder(base_model, base_db):
    # 设置表名
    __tablename__ = DB_PREFIX + "data_order"
    # 用户ID
    uid = Column(Integer, default=0, comment="用户ID")
    company_id = Column(Integer, default=0, comment="公司ID")
    shop_num = Column(String(150), nullable=True, comment="店铺编号")
    shop_name = Column(String(150), nullable=True, comment="店铺名称")
    day = Column(Date, default=datetime.now, comment="日期")
    order_sn = Column(String(150), nullable=True, comment="订单编号")
    order_time = Column(Integer, default=0, comment="订单时间")
    order_status = Column(String(150), nullable=True, comment="订单状态")
    goods_id = Column(String(150), nullable=True, comment="商品id")
    goods_name = Column(String(255), nullable=True, comment="商品名称")
    goods_price = Column(DECIMAL, default=0.00, comment='商品价格')
    goods_number = Column(DECIMAL, default=0.00, comment='商品数量')
    order_amount = Column(DECIMAL, default=0.00, comment='订单总额')
    goods_amount = Column(DECIMAL, default=0.00, comment='商品总额')
    out_sku_sn = Column(String(255), nullable=True, comment='规格编码')
    spec = Column(String(255), nullable=True, comment='规格')
    thumb_url = Column(String(255), nullable=True, comment='商品略缩图')

    # 初始化
    def __init__(self, id, uid, company_id, mall_id, mall_name, day, order_sn, order_time, order_status, goods_id,
                 goods_name, goods_price, goods_number, order_amount, goods_amount, out_sku_sn, spec, thumb_url):
        self.id = id
        self.uid = uid
        self.company_id = company_id
        self.shop_num = mall_id
        self.shop_name = mall_name
        self.day = day
        self.order_sn = order_sn
        self.order_time = order_time
        self.order_status = order_status
        self.goods_id = goods_id
        self.goods_name = goods_name
        self.goods_price = goods_price
        self.goods_number = goods_number
        self.order_amount = order_amount
        self.goods_amount = goods_amount
        self.out_sku_sn = out_sku_sn
        self.spec = spec
        self.thumb_url = thumb_url

    def __str__(self):
        return "数据{}".format(self.id)
